package com.example.shop.merchant.vo;

import com.example.shop.merchant.dto.MerchantBriefInfo;
import com.example.shop.pojo.Merchant;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDate;

@Data
@NoArgsConstructor
public class MerchantPublicInfo extends MerchantBriefInfo {
    /**
     * 商家的产品和服务的综合质量评分
     */
    protected Integer qualityGrade;
    /**
     * 商家的简介
     */
    private String introduction;
    /**
     * 商家所在位置的经度
     */
    private Double longitude;
    /**
     * 商家所在位置的纬度
     */
    private Double latitude;
    /**
     * 商家所在的区域，如：广东省肇庆市
     */
    private String area;
    /**
     * 商家的详细地址
     */
    private String detailedAddress;
    /**
     * 商家号
     */
    private String account;
    /**
     * 商家的电话号
     */
    private String phone;
    /**
     * 商家的状态：在线、下线
     */
    private byte merchantState;
    /**
     * 商家的注册时间
     */
    private LocalDate registerDate;

    public static MerchantPublicInfo getMerchantPublicInfo(Merchant merchant){
        MerchantPublicInfo publicInfo = new MerchantPublicInfo();
        publicInfo.id = merchant.getMerchantId();
        publicInfo.setAvatar(merchant.getMerchantAvatar());
        publicInfo.name = merchant.getMerchantName();
        publicInfo.qualityGrade = merchant.getMerchantQualityGrade();
        publicInfo.introduction = merchant.getMerchantIntroduction();
        publicInfo.latitude = merchant.getMerchantLatitude();
        publicInfo.longitude = merchant.getMerchantLongitude();
        publicInfo.area = merchant.getMerchantArea();
        publicInfo.detailedAddress = merchant.getMerchantDetailedAddress();
        publicInfo.account = merchant.getMerchantAccount();
        publicInfo.phone = merchant.getMerchantPhone();
        publicInfo.merchantState = merchant.getMerchantState();
        publicInfo.registerDate = merchant.getMerchantRegisterDate();
        return publicInfo;
    }
}
